package com.tencent.iov.cowin.befsale.clue.repository.cus.impl;

import com.github.pagehelper.Page;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.request.CusUnbindRequest;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.response.CusUnbindResponse;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.request.ClueIntentionGradeDataRequest;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.request.QueryCustomerRequest;
import com.tencent.iov.cowin.befsale.clue.dao.cus.DealerCustomerDao;
import com.tencent.iov.cowin.befsale.clue.domain.cus.po.DealerCustomer;
import com.tencent.iov.cowin.befsale.clue.repository.cus.DealerCustomerManager;
import com.tencent.iov.cowin.befsale.clue.value.contants.ServiceConstant;
import com.software.boot.dao.annotation.TargetDataSource;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @Describe: 经销商客户表主表+客户好友关联表_Manager实现层
 * @author: xiamu
 * @created: 2021-12-21 17:29:50
 * @version: 1.0
 */
@Service
public class DealerCustomerManagerImpl implements DealerCustomerManager {

    @Autowired
    private DealerCustomerDao dealerCustomerDao;

    /**
     * 通过ID获取详细信息
     *
     * @param: id 主键ID
     * @return: DealerCustomer对象
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_READ)
    public DealerCustomer getDetailById(Long id) {
        return dealerCustomerDao.getDetailById(id);
    }

    /**
     * 单条数据插入DealerCustomer
     *
     * @param request 保存请求参数
     * @return 插入的条数
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_WRITE)
    public int insert(DealerCustomer request) {
        return dealerCustomerDao.insert(request);
    }

    /**
     * 批量插入DealerCustomer
     *
     * @param requests 批量插入参数
     * @return 批量插入的条数
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_WRITE)
    public int insertBatch(List<DealerCustomer> requests) {
        return dealerCustomerDao.insertBatch(requests);
    }

    /**
     * 单条DealerCustomer更新
     *
     * @param request 更新参数
     * @return 更新的条数
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_WRITE)
    public int update(DealerCustomer request) {
        return dealerCustomerDao.update(request);
    }

    /**
     * 单条DealerCustomer删除
     *
     * @param id 主键ID
     * @return 删除的条数
     */
    @Override
    public int delete(Integer id) {
        return dealerCustomerDao.delete(id);
    }

    /**
     * 根据条件查询对象list列表
     *
     * @param request 查询参数
     * @return 查询结果
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_READ)
    public List<DealerCustomer> getListByParam(DealerCustomer request) {
        return dealerCustomerDao.getListByParam(request);
    }

    /**
     * 根据条件查询对象page记录
     *
     * @param request 查询参数
     * @param rowBounds 分页参数
     * @return 查询结果
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_READ)
    public Page<DealerCustomer> getPageByParam(DealerCustomer request, RowBounds rowBounds) {
        return dealerCustomerDao.getPageByParam(request, rowBounds);
    }

    /**
     * 根据条件查询单个对象
     *
     * @param request 查询条件
     * @return 查询结果
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_READ)
    public DealerCustomer getOneByParam(DealerCustomer request) {
        return dealerCustomerDao.getOneByParam(request);
    }

    @Override
    public List<DealerCustomer> checkDealerCustomerPhone(DealerCustomer dealerCustomer) {
        return dealerCustomerDao.checkDealerCustomerPhone(dealerCustomer);
    }

    @Override
    public List<DealerCustomer> checkDealerCustomerOneId(DealerCustomer dealerCustomer) {
        return dealerCustomerDao.checkDealerCustomerOneId(dealerCustomer);
    }

    @Override
    public List<CusUnbindResponse> findOemCusUnbind(CusUnbindRequest cusUnbindRequest) {
        return dealerCustomerDao.findOemCusUnbind(cusUnbindRequest);
    }

    @Override
    public List<CusUnbindResponse> findDealerCusUnbind(CusUnbindRequest cusUnbindRequest) {
        return dealerCustomerDao.findDealerCusUnbind(cusUnbindRequest);
    }

    /**
     * 获取客户转线索的数量
     * add by zly
     * 2022-01-15
     * @param clueDataRequest
     * @return
     */
    @Override
    public Long getEmpBindCount(ClueIntentionGradeDataRequest clueDataRequest) {
        return dealerCustomerDao.getEmpBindCount(clueDataRequest);
    }

    @Override
    public DealerCustomer getCustomerInfoWithPhone(QueryCustomerRequest request) {
        return dealerCustomerDao.getCustomerInfoWithPhone(request);
    }


}
